package com.vdf.sisconsolid.persistencemodule.converter;

import java.util.ArrayList;
import java.util.List;

import com.vdf.sisconsolid.persistencemodule.dto.KeyValueBean;
import com.vdf.sisconsolid.persistencemodule.model.City;
import com.vdf.sisconsolid.persistencemodule.model.Neighborhood;
import com.vdf.sisconsolid.persistencemodule.model.Province;
import com.vdf.sisconsolid.persistencemodule.model.Street;

public class AddressConverter {

	public static List<KeyValueBean> toProvinceKeyValue(List<Province> provinceList) {
		List<KeyValueBean> provinceBeanList = new ArrayList<KeyValueBean>();
		for (Province p : provinceList) {
			KeyValueBean pBean = new KeyValueBean();
			pBean.setKey(p.getId());
			pBean.setValue(p.getName());
			
			provinceBeanList.add(pBean);
		}
		return provinceBeanList;
	}
	
	public static List<KeyValueBean> toCityKeyValue(List<City> cityList) {
		List<KeyValueBean> cityBeanList = new ArrayList<KeyValueBean>();
		for (City city : cityList) {
			KeyValueBean pBean = new KeyValueBean();
			pBean.setKey(city.getId());
			pBean.setValue(city.getName());
			cityBeanList.add(pBean);
		}
		return cityBeanList;
	}

	public static List<KeyValueBean> toNeighborhoodKeyValue(
			List<Neighborhood> neighborhoodList) {
		List<KeyValueBean> neighborhoodBeanList = new ArrayList<KeyValueBean>();
		for (Neighborhood nh : neighborhoodList) {
			KeyValueBean pBean = new KeyValueBean();
			pBean.setKey(nh.getId());
			pBean.setValue(nh.getName());
			neighborhoodBeanList.add(pBean);
		}
		return neighborhoodBeanList;
	}

	public static List<KeyValueBean> toStreetKeyValue(List<Street> streetList) {
		List<KeyValueBean> streetBeanList = new ArrayList<KeyValueBean>();
		for (Street street : streetList) {
			KeyValueBean pBean = new KeyValueBean();
			pBean.setKey(street.getId());
			pBean.setValue(street.getName());
			streetBeanList.add(pBean);
		}
		return streetBeanList;
	}

}
